package com.wutong.teacher_server.service.impl;

import com.wutong.teacher_server.entity.Files;
import com.wutong.teacher_server.mapper.FilesMapper;
import com.wutong.teacher_server.service.FilesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wutong
 * @since 2020-11-05
 */
@Service
public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements FilesService {
    @Autowired
    FilesMapper filesMapper;

    @Override
    public boolean saveFiles(Files file) {

        String fileType = file.getFileType();
        if (fileType.startsWith("image")) {
            file.setIsImg(0);//是图片
        }else{
            file.setIsImg(1);
        }
        int insert = filesMapper.insert(file);
        if(insert > 0){
            return true;
        }
        return false;
    }
}
